<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .parent {
            display: flex;
            width: 600px;
            height: 120px;
            border: 1px solid #999;
            align-items: baseline;
        }
        .item {
            width: 100px;
            background-color: orange;
            font-size: 40px;
            color: #fff;
            text-align: center;
            border: 1px solid #e1e1e1;
        }
        .item:first-child {
            font-size: 20px;
        }
    </style>
</head>
<body>
    <br>
    <p>首先我们设置flex容器baseline对齐，然后点击下面的单选框，给第2个flex子项设置不同align-self属性值，观察其表现：</p>
    <form action="#" onsubmit="return false;">
        <label for=""><input type="radio" name="option" value="auto" data-attr="alignSelf">align-selft: auto;</label>
        <label for=""><input type="radio" name="option" value="flex-start" data-attr="alignSelf">align-selft: flex-start;</label>
        <label for=""><input type="radio" name="option" value="flex-end" data-attr="alignSelf">align-selft: flex-end;</label>
        <label for=""><input type="radio" name="option" value="baseline" data-attr="alignSelf">align-selft: baseline;</label>
        <label for=""><input type="radio" name="option" value="stretch" data-attr="alignSelf">align-selft: stretch;</label>
    </form>
    <div class="parent">
        x
        <div class="item">1</div>
        <div class="item item2">2</div>
        <div class="item">3</div>
        <div class="item">4</div>
    </div>
    <script>
        let inputs = document.querySelectorAll('input[name=option]');
        let box = document.querySelector('.item2');
        Array.from(inputs).forEach((ele, i) => {
            ele.onchange = function() {
                let value = this.value;
                let prop = this.dataset.attr;
                box.style[prop] = value;
            }
        })
    </script>
</body>
</html>